<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Response;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|+--------+-----------+----------------------------+-----------------+------------------------------------------------+--------------+
| Domain | Method    | URI                        | Name            | Action                                         | Middleware   |
+--------+-----------+----------------------------+-----------------+------------------------------------------------+--------------+
|        | GET|HEAD  | /                          |                 | Closure                                        | web          |
|        | GET|HEAD  | api/twitter                | twitter.index   | App\Http\Controllers\TwitterController@index   | api          |
|        | POST      | api/twitter                | twitter.store   | App\Http\Controllers\TwitterController@store   | api          |
|        | GET|HEAD  | api/twitter/create         | twitter.create  | App\Http\Controllers\TwitterController@create  | api          |
|        | GET|HEAD  | api/twitter/{twitter}      | twitter.show    | App\Http\Controllers\TwitterController@show    | api          |
|        | PUT|PATCH | api/twitter/{twitter}      | twitter.update  | App\Http\Controllers\TwitterController@update  | api          |
|        | DELETE    | api/twitter/{twitter}      | twitter.destroy | App\Http\Controllers\TwitterController@destroy | api          |
|        | GET|HEAD  | api/twitter/{twitter}/edit | twitter.edit    | App\Http\Controllers\TwitterController@edit    | api          |
|        | GET|HEAD  | api/user                   |                 | Closure                                        | api,auth:api |
+--------+-----------+----------------------------+-----------------+------------------------------------------------+--------------+

*/

//Route::middleware('auth:api')->get('/user', function (Request $request) {
//    return $request->user();
//});
//
////创建一个资源路由，对应TwitterController,中的四种http请求格式 可使用php artisan route:list
//Route::middleware('api')->resource('/twitter','TwitterController');

$api = app('Dingo\Api\Routing\Router');
$api->version('v1', function ($api) {
    $api->group(['namespace' => 'App\Api\Controllers'], function ($api) {
        // Endpoints registered here will have the "foo" middleware applied.
        $api->get('/twitter', 'TwitterController@index');
        $api->get('/club', 'ClubController@index');
        $api->get('/twitter/{id}', 'TwitterController@show');
        $api->get('/club/{id}', 'ClubController@show');
        $api->post('/user/login', 'AuthController@authenticate');
        $api->get('/twitter', 'AuthController@test');
        $api->get('/train/{id}', 'TrainController@show');
        $api->get('/award/{id}', 'AwardController@show');
        $api->get('/clubclass/{id}', 'AwardController@show');
        $api->get('/activity/{id}', 'TrainController@show');

    });
});
